package news.dao;

import news.util.BaseDao;

/**
 * @author JiangJ
 * @date 2022/3/2 20:28
 */
public class UpdateTopicImpl implements IUpdateTopicDao {
    BaseDao baseDao = new BaseDao();

    /**
     * 更新
     *
     * @param id
     * @param topicName
     */
    @Override
    public void updateTopic(Integer id, String topicName) {
        try {
            baseDao.openDB();
            String sql = "update news_topic set topicname=? where id = ?";
            baseDao.ps = baseDao.conn.prepareStatement(sql);
            baseDao.ps.setString(1, topicName);
            baseDao.ps.setInt(2, id);
            baseDao.ps.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
